package com.amadeus.spin.devtool.soap.shooter.process;

/**
 * Title:        Global OCG 1Ares/CT project
 * Description:  Make a pause and print out session information if availbale
 * This class is called from the soap shooter
 * Copyright:    Copyright (c) 2001
 * Company:      aMaDEUS
 * @author
 * @version 1.0
 */

import java.io.IOException;

import org.apache.log4j.Logger;
import org.w3c.dom.Node;

import com.amadeus.spin.devtool.soap.shooter.FatalException;
import com.amadeus.spin.devtool.soap.shooter.ProcessOutput;

/**
 * MakePauseOnOutput is a simple classes that makes a pause until Enter is
 * pressed. MakePauseOnOutput is called from the SOAP shooter.
 * 
 */
public class MakePauseOnOutput implements ProcessOutput {
  private static Logger m_log = Logger.getLogger(AddDelayToOutput.class);

  public MakePauseOnOutput() {
  }

  /**
   * For the given xmlOutput string, process the config node
   */
  @Override
  public void processOutput(String xmlOutput, Node config,
      com.amadeus.spin.util.soapshooter.Shooter shooter) throws FatalException {
    try {
      m_log.info("SoapShooter is paused. Press <Enter> to continue.");
      pause();
    }
    catch (IOException e) {
      m_log.error("Error in during the 'MakePauseOnOutput' : ", e);
      throw new FatalException("IOException caught", e);
    }
  }

  public void pause() throws IOException {
    System.in.read();
    System.in.skip(System.in.available());
  }
}
